import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// import whoami from '@feidao/web/atom/browser/msg/whoami';
import s_get from '@dfeidao/atom-web/storage/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';


import P02 from './P02';
import P03 from './P03';
// import P05 from './P05';

import set from '@dfeidao/atom-web/local/set';

export default async function a005(fd: IFeidaoAiBrowserComponent, args: { formid: string, client_point_id: string, _id: string, form: string, client_style: string, systemid: string, refsystemid: string, text: string, formname: string, priority: string, description: string, icon: string, background: string, is_show: string }) {
	//  调用事件
	fd.data.node.classList.remove('display-n');
	set(fd, 'formid', args.formid);
	set(fd, 'client_point_id', args.client_point_id);
	set(fd, 'id', args._id);
	set(fd, 'form', args.form);
	set(fd, 'menu_name', args.text);
	// fd.data.node.querySelector<HTMLSpanElement>('#client_style1').innerHTML = args.client_style;

	// const user = await whoami(get_user_info);

	const productid = await s_get('productid');

	const res1 = await nodejs<{ dataArray: string[] }>('menu/zj-000002/s001', { productid });
	render(fd, res1, P02, 'P02', 'inner');
	const systemid = args.systemid;
	const res2 = await nodejs<{ dataArray: string[] }>('menu/zj-000002/s002', { productid, systemid });
	render(fd, res2, P03, 'P03', 'inner');
	// const res3 = await nodejs<{ dataArray: string[] }>('menu/zj-000001/s005', { productid });
	// render(fd, res3, P05, 'P05', 'inner');
	fd.data.node.querySelector<HTMLSpanElement>('#client_style1').innerHTML = args.client_style;
	fd.data.node.querySelector<HTMLSelectElement>('#zj3systemid').value = systemid;
	fd.data.node.querySelector<HTMLSelectElement>('#zj3refsystemid').value = args.refsystemid;
	const f = fd.data.node.querySelector<HTMLFormElement>('#pub_menu_form1');
	const n = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id="isshow"]');
	f.menu_name.value = args.text;
	f.formname.value = args.formname;
	f.priority.value = args.priority;
	f.description.value = args.description;
	f.icon.value = args.icon;
	f.background.value = args.background;
	console.log(args);
	// show_type
	if (args.is_show) {
		n.checked = true;
	} else {
		n.checked = false;
	}
}
